﻿using System;

namespace LayeredArchitectureSample.DomainModel
{
    [GenerateDataTransferObject(TemplateName = "DefaultDtoTemplate.tt")]
    public class Ware : DomainObject
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="code"></param>
        /// <exception cref="ArgumentException"></exception>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        public Ware(long id, string code) : base(id)
        {
            if (string.IsNullOrEmpty(code))
            {
                throw new ArgumentException("Failed to create a ware: you haven't provided ware's code");
            }

            Code = code;
        }

        public string Code { get; private set; }

        public bool Equals(Ware other)
        {
            return base.Equals(other);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            return Equals(obj as Ware);
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }
    }
}